package com.example.travel.service;

import com.example.travel.mapper.CategoryMapper;
import com.example.travel.pojo.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    //获取所有数据
    public List<Category> getAllInfo(){

        return categoryMapper.getAllInfo();
    }

    //添加数据
    public int addInfo(Category category){

        return categoryMapper.insert(category);
    }

    //通过主键查询信息
    public Category getInfo(Integer cId){

        return categoryMapper.selectById(cId);
    }

    //更新，通过id
    public int update(Category category){

        return categoryMapper.updateById(category);
    }

    //删除
    public int delete(Integer cId){

        return categoryMapper.deleteById(cId);
    }

}
